***************
* Information *
***************

* This files reproduces analyses for Study 2 in 
* Michael Bang Petersen, "Healthy Outgroup Members Are Psychologically Represented as Infected Ingroup Members", Psychological Science

*************
* Recodings *
*************

* Identifying number of subjects (only subjects who completed the study are included in the analyses)

ta V10

* Generation of recall measures

gen recall1=.
replace recall1=0 if Q21==1 
replace recall1=1 if Q21==3 | Q21==5 | Q21==6
replace recall1=2 if Q21==2 | Q21==4 | Q21==7 | Q21==8
replace recall1=0 if Q69==1 
replace recall1=1 if Q69==3 | Q69==5 | Q69==6
replace recall1=2 if Q69==2 | Q69==4 | Q69==7 | Q69==8
ta recall1

gen recall2=.
replace recall2=0 if Q33==2 
replace recall2=1 if Q33==4 | Q33==7 | Q33==8
replace recall2=2 if Q33==1 | Q33==3 | Q33==5 | Q33==6
replace recall2=0 if Q68_0==2 
replace recall2=1 if Q68_0==4 | Q68_0==7 | Q68_0==8
replace recall2=2 if Q68_0==1 | Q68_0==3 | Q68_0==5 | Q68_0==6
ta recall2

gen recall3=.
replace recall3=0 if Q34==3 
replace recall3=1 if Q34==1 | Q34==5 | Q34==6
replace recall3=2 if Q34==2 | Q34==4 | Q34==7 | Q34==8
replace recall3=0 if Q69_0==3 
replace recall3=1 if Q69_0==1 | Q69_0==5 | Q69_0==6
replace recall3=2 if Q69_0==2 | Q69_0==4 | Q69_0==7 | Q69_0==8
ta recall3

gen recall4=.
replace recall4=0 if Q35==4 
replace recall4=1 if Q35==2 | Q35==7 | Q35==8
replace recall4=2 if Q35==1 | Q35==3 | Q35==5 | Q35==6
replace recall4=0 if Q70==4 
replace recall4=1 if Q70==2 | Q70==7 | Q70==8
replace recall4=2 if Q70==1 | Q70==3 | Q70==5 | Q70==6
ta recall4

gen recall5=.
replace recall5=0 if Q36==5 
replace recall5=1 if Q36==1 | Q36==3 | Q36==6
replace recall5=2 if Q36==2 | Q36==4 | Q36==7 | Q36==8
replace recall5=0 if Q71==5 
replace recall5=1 if Q71==1 | Q71==3 | Q71==6
replace recall5=2 if Q71==2 | Q71==4 | Q71==7 | Q71==8
ta recall5

gen recall6=.
replace recall6=0 if Q37==6 
replace recall6=1 if Q37==1 | Q37==3 | Q37==5
replace recall6=2 if Q37==2 | Q37==4 | Q37==7 | Q37==8
replace recall6=0 if Q72==6 
replace recall6=1 if Q72==1 | Q72==3 | Q72==5
replace recall6=2 if Q72==2 | Q72==4 | Q72==7 | Q72==8
ta recall6

gen recall7=.
replace recall7=0 if Q38==7 
replace recall7=1 if Q38==2 | Q38==4 | Q38==8
replace recall7=2 if Q38==1 | Q38==3 | Q38==5 | Q38==6
replace recall7=0 if Q73==7 
replace recall7=1 if Q73==2 | Q73==2 | Q73==8
replace recall7=2 if Q73==1 | Q73==3 | Q73==5 | Q73==6
ta recall7

gen recall8=.
replace recall8=0 if Q39==8 
replace recall8=1 if Q39==2 | Q39==4 | Q39==7
replace recall8=2 if Q39==1 | Q39==3 | Q39==5 | Q39==6
replace recall8=0 if Q75==8 
replace recall8=1 if Q75==2 | Q75==2 | Q75==7
replace recall8=2 if Q75==1 | Q75==3 | Q75==5 | Q75==6
ta recall8

egen correct=anycount(recall1 recall2 recall3 recall4 recall5 recall6 recall7 recall8), values(0)
egen between=anycount(recall1 recall2 recall3 recall4 recall5 recall6 recall7 recall8), values(2)
egen within=anycount(recall1 recall2 recall3 recall4 recall5 recall6 recall7 recall8), values(1)

sum between within correct if V10==1

* Generation of experimental variable

gen exp=.
replace exp=0 if Q21>0 & Q21<9
replace exp=1 if Q69>0 & Q69<9
ta exp

label define exp 0 "Healthy White vs. Healthy Indian" 1 "Sick White vs. Healthy Indian"
label values exp exp
ta exp

* Generation of pathogen disgust scale

alpha Q77_1 Q77_2 Q77_3 Q77_4 Q77_5 Q77_6 Q77_7, gen(pathogen)
sum pathogen

************
* Analyses *
************

* Generating Figure 1, Panel B and associated analyses

reg within exp if V10==1
margins, dydx(exp) level(95)
estimates store m1
reg between exp if V10==1
margins, dydx(exp) level(95)
estimates store m2
reg correct exp if V10==1
margins, dydx(exp) level(95)
estimates store m3

coefplot (m3, keep("exp")) (m2, keep("exp")) (m1, keep("exp")), ///
recast(bar) barw(.23) ciopts(recast(rcap) lpattern(dash) lcolor(black)) citop msize(medlarge) vertical yscale(range(-1.25 1)) ///
title("B. Study 2: Representative Sample") ylabel(-1(.20)1, nogrid) yline(0, lstyle(foreground)) xlabel(none) ytitle("Effect of Infection Cues in Ingroup Members") ///
legend (order(1 3 5) ///
	label(1 "Correct Recall") ///
	label(3 "Between-Group Errors") ///
	label(5 "Within-Group Errors") col(1)) ///
	scheme(s2mono) graphregion(lcolor(black) fcolor(white))
graph display, ysize(3) xsize(2.5)

* Correlations between pathogen disgust and recall measures in the treatment condition

ci2 pathogen correct if exp==1 & V10==1, corr
ci2 pathogen between if exp==1 & V10==1, corr
ci2 pathogen within if exp==1 & V10==1, corr

* Interactions between treatment and pathogen disgust

reg correct i.exp##c.pathogen if V10==1
reg between i.exp##c.pathogen if V10==1
reg within i.exp##c.pathogen if V10==1

